var GownFullHTMLInputTextAdapter = GownFullObjectAdapter.extend({
	keydown_handler: null,
	keyup_handler: null,
	keypress_handler: null,
	focus_handler: null,
	constructor: function(obj)
	{
		this.base(obj);
	},
	clone: function(obj)
	{
		return new GownFullHTMLInputTextAdapter(obj);
	},
	GetCursorXY: function()
	{
		// Just get the position of the input text...
		var pos = JSVKBrowserExtension.getOffset(this.obj);

		return new Array(pos.x,pos.y);
	},
	SendString: function(o,s)
	{
		this.SetFocus();
		if(this.obj.selectionStart != null) {
			var last_scrollleft = this.obj.scrollLeft;
			var last_scrolltop = this.obj.scrollTop;
			var start = this.obj.selectionStart;
			var end = this.obj.selectionEnd;
			var len = this.obj.value.length;

			this.obj.value = this.obj.value.substring(0,start) + s + this.obj.value.substring(end,len);
			start = start + s.length;
			end = start;
			if(this.obj.setSelectionRange) this.obj.setSelectionRange(start,end);
			else {
				this.obj.selectionStart = start;
				this.obj.selectionEnd = end;
			}
			this.obj.scrollLeft = last_scrollleft;
			this.obj.scrollTop = last_scrolltop;
		}
		else if(document.selection) {
			var sel = document.selection.createRange();
			sel.text = s;
			sel.collapse(false);
			sel.select();
		}
		else return false;
		return true;
	},
	SetFocus: function()
	{
		if(this.obj.focus) this.obj.focus();
		return true;
	},
	GetCursor: function()
	{
		return null;
	},
	RestoreCursor: function(cur)
	{
		return null;
	},
	AttachHandler: function(keydown_handler,keypress_handler,keyup_handler,focus_handler)
	{
		var x = this;

		this.keydown_handler = keydown_handler;
		this.keyup_handler = keyup_handler;
		this.keypress_handler = keypress_handler;
		this.focus_handler = focus_handler;

		if(GownFullBrowserDetect.use_key_addEventListener) {
			this.obj.addEventListener("keydown", function(e) { return x.keydown_handler(e); },false);
			this.obj.addEventListener("keypress", function(e) { return x.keypress_handler(e); },false);
			this.obj.addEventListener("keyup", function(e) { return x.keyup_handler(e); },false);
			this.obj.addEventListener("focus",function(e) { return x.focus_handler(e); },false);
		}
		else if(GownFullBrowserDetect.use_attachEvent) {
			this.obj.attachEvent("onkeydown", function(e) { return x.keydown_handler(e); });
			this.obj.attachEvent("onkeypress", function(e) { return x.keypress_handler(e); });
			this.obj.attachEvent("onkeyup", function(e) { return x.keyup_handler(e); });
			this.obj.attachEvent("onfocus",function(e) { return x.focus_handler(e); });
		}
		else {
			this.obj.onkeydown = function() { return x.keydown_handler(window.event); }
			this.obj.onkeypress = function() { return x.keypress_handler(window.event); }
			this.obj.onkeyup = function() { return x.keyup_handler(window.event); }
			this.obj.onfocus = function() { return x.focus_handler(window.event); }
		}
	},
	GetSelection: function()
	{
		try { // should be happen only on IE
			return document.selection.createRange();
		}
		catch(e) {}
		return true;
	},
	RestoreSelection: function(sel)
	{
		try { // should be happen only on IE
			sel.select();
		}
		catch(e) {}
		return true;
	}
});

